import React, { useState } from 'react';
import { Button, Modal } from 'antd';
import { connect } from 'umi';


const delservice = (props: any) => {
  const [isModalOpen, setIsModalOpen] = useState(false);
  // console.log(props);

  const showModal = () => {
    setIsModalOpen(true);
  };

  const handleOk = () => {
    // console.log(props.delId);
    if(props.type === '客服'){
      props.dispatch({type:'area/delservice',payload: props.delId})
    }else if(props.type === '楼盘'){
      props.dispatch({type:'area/delhouse',payload: props.id})
    }else if(props.type === '沙盘'){
      props.dispatch({type:'area/delsand',payload: props.id})
    }else if(props.type === '二手房'){
      props.dispatch({type:'area/delsecound',payload: props.id})
    }
    props.close(props.id)
  };

  const handleCancel = () => {
    props.close()
  };

  return (
    <div>
      <Modal
      getContainer={document.body}
        title="提示信息"
        open={props.open}
        onOk={handleOk}
        onCancel={handleCancel}
        width="300px"
        centered
      >
        {props.type==='客服'?`确定要删除客服【${props.name}】吗？`:`确定要删除 ${props.name} 吗？`}
      </Modal>
    </div>
  );
};

export default connect()(delservice);
